package com.wk.service.impl;

import com.wk.dao.CmfzAdminRoleDao;
import com.wk.entity.CmfzAdmin;
import com.wk.entity.CmfzAdminRole;
import com.wk.entity.Result;
import com.wk.service.CmfzAdminRoleService;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class CmfzAdminRoleServiceImpl implements CmfzAdminRoleService {

    @Autowired
    private CmfzAdminRoleDao cmfzAdminRoleDao;

    public Map insert(CmfzAdminRole cmfzAdminRole) {
        Map map = new HashMap();
//        try {
//            CmfzAdmin cmfzAdmin = cmfzAdminRole.getCmfzAdmin();
//            String password = cmfzAdmin.getPassword();
//            for (int i = 0; i < 1024; i++) {
//                cmfzAdmin.setPassword( DigestUtils.md5Hex(password));
//            }
//            cmfzAdminRole.setAdminId(cmfzAdmin.getId());
//            cmfzAdminRoleDao.insert(cmfzAdminRole);
//            map.put("data","添加成功");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        return map;
    }

    @Override
    public Result findOne(Integer id) {
        CmfzAdminRole one = cmfzAdminRoleDao.findOne(id);
        return new Result().setData(one);
    }
}
